<html>
  <head>
  <Title>Add or Edit a question</title>
    <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
    <link type="text/css" rel="stylesheet" href="/stylesheets/question_search.css" />
 <script language="JavaScript">
	function CheckMode() 			// detect if in Edit or Append/New mode mode	
	{ 
        	return true;
	}
	
	function CheckAndSubmit() {		// Check value ranges for correct-field
		var elCorrect = document.getElementById("correct");		
		var intCorrect = parseInt(elCorrect.value);		
		
		if (isNaN(intCorrect)) {
			elCorrect.focus(); elCorrect.select();
			alert("'Correct Answer' field must be a number.");     			
			return false;
  		}	
		
		if (intCorrect > 3 || intCorrect < 0) { 
			elCorrect.focus(); elCorrect.select();
			alert ("Wrong range for 'Correct Answer' field. \n Range is from 0 up till 3.");
			return false;  
		}
				
		document.frmEditQuestion.submit();
	}
</script>
</head>
  <body>
      <div><h2>Create or Edit a question</h2></div>
      <form action="/question_submit" method="post" id="frmEditQuestion" name="frmEditQuestion"></br>
      <hr><br/>
      <div><input type="hidden" name="id" value="{{ id }}"></div>
     
      <div class="labelEdit">Question</div><textarea class="myTextInput" cols="2" rows="2"  id="question" name="question">{{ question }}</textarea></div>
      <br/>
      <div><div class="labelEdit">Alternative 1</div><textarea class="myTextInput" cols="2" rows="2" id="alt0" name="alt0">{{ alt0 }}</textarea></div>
      <div><div class="labelEdit">Alternative 2</div><textarea class="myTextInput" cols="2" rows="2" id="alt1" name="alt1">{{ alt1 }}</textarea></div>
      <div><div class="labelEdit">Alternative 3</div><textarea class="myTextInput" cols="2" rows="2" id="alt2" name="alt2">{{ alt2 }}</textarea></div>
      <div><div class="labelEdit">Alternative 4</div><textarea class="myTextInput" cols="2" rows="2" id="alt3" name="alt3">{{ alt3 }}</textarea></div>	
      <br/>
      <div class="labelEdit">Correct Answer</div><input class="myIntText" type="text" name="correct" id="correct" value="{{ correct }}">
      &nbsp; NB: Counting of alternatives start with 0 up till 3.
      </div>
      <br/>
      <hr>	
      <div><input class="myButton" onClick="CheckAndSubmit();" type="button" id="Save" value="Save"></div>
    </form>
<hr>
<br><br><a href="/">Start page</a>  
</body>
</html>

